#include <string>
#include <iostream>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

class MyException {
 public:
  string message;
  MyException();
  MyException(string s): message(s) {}
  void what() const {
    cout << "Error: MyException :: " << this->message << endl;
  };
};

int main(int, char**) {
  string window_name = "Template";
  VideoCapture cap = VideoCapture(0);
  if (!cap.isOpened()) throw MyException("Failed to open Video.");
  while (true) {
    Mat frame;
    cap.read(frame);
    imshow(window_name, frame);
    if (waitKey(1) == 27) break;
  }
  return 0;
}
